const fetchRoleList = (size) => {
  let list = [];
  for (let index = 0; index < size; index++) {
    list = list.concat({
      "id|+1": index + 1,
      icon: "icon iconfont icon-home",
      title: "@cname",
      show: true,
      type: 1,
      sort: 1,
      href: "/home",
      operate: "",
      createTime: "@datetime",
    });
    console.log(list, "===list====");
  }
  return list;
};

export default [
  {
    url: "/api/permission/list",
    method: "get",
    response: (options) => {
      const urlParams = new URLSearchParams(options.url.split("?")[1] || "");
      const list = fetchRoleList(urlParams.get("pageSize"));
      console.log(list, urlParams, "urlParams");
      return {
        code: 200,
        total: 12,
        data: list,
      };
    },
  },
  {
    url: "/api/permission/add",
    method: "post",
    response: () => {
      return {
        code: 200,
        data: {
          "id|+1": "@id",
          icon: "icon iconfont icon-home",
          title: "@cname",
          show: true,
          type: 1,
          sort: 1,
          href: "/home",
          operate: "",
        },
      };
    },
  },
  {
    url: "/api/permission/organization",
    method: "get",
    response: () => {
      return {
        code: 200,
        data: [
          {
            id: 1,
            name: "组织一",
            children: [
              {
                id: 2,
                name: "队一",
              },
            ],
          },
        ],
      };
    },
  },
];
